﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Net.Sockets;
using System.Net;
using System.Threading;
using System.Data;
using System.Windows;
using System.Windows.Forms;
using EMC;

namespace SaunaClient.View.Admin_Client
{
    public class AdminClientControler
    {
        public static User state;
        private static List<Form> forms;
        public static databaseConfiguration config = new databaseConfiguration("db_settings.xml");
 
        

        public AdminClientControler()
        {
           // NewUserForm nwUserForm = new NewUserForm();
        //    MainForm mnForm = new MainForm();

            forms = new List<Form>();

            forms.Add(new MainForm());
            forms.Add(new NewUserForm());
            forms.Add(new DeleteUser());
            forms.Add(new EditUser());

            state = new User();

        }




        public void ShowForm(System.Type formName)
        {

            //Loop through the forms and check for an instance
            foreach (Form form in forms)
            {
                if (form.GetType() == formName)
                {
                    form.Show();
                }
                else
                {
                    form.Hide();
                }
            }
        }

        // Chiaki Added 2011.10.25
        public void ShowForm(System.Type formName, string[] arraySelectedUser)
        {

            //Loop through the forms and check for an instance
            foreach (Form form in forms)
            {
                if (form.GetType() == formName)
                {
                    form.Show();
                    if (formName == typeof(EditUser))
                    {
                        EditUser editUser = form as EditUser;
                        editUser.InitialazeEditUser(arraySelectedUser);
                    }
                    else if (formName == typeof(DeleteUser))
                    {
                        DeleteUser deleteUser = form as DeleteUser;
                        deleteUser.InitialazeEditUser(arraySelectedUser);
                    }
                }
                else
                {
                    form.Hide();
                }
            }
        }


        public static void userName(string name)
        {
            state.username = name;
        }

        public static void userPass(string pass)
        {
            state.password = pass;
        }

        public static void userEmail(string email)
        {
            state.email = email;
        }

        public static void userPhone(string phone)
        {
            state.phone = phone;
        }

        public static void userFirstName(string first)
        {
            state.firstname = first;
        }

        public static void userLastName(string last)
        {
            state.lastname = last;
        }


    }
}